﻿@model PessModel.Registration

@{
    ViewBag.Title = "Registration";
    IQueryable<PessModel.RegistrationOption> lstBasicItems = ViewBag.BasicItems;
    IQueryable<PessModel.RegistrationOption> lstAddonItems = ViewBag.AddonItems;
    PessModel.RegistrationOption BasicItem = null;
    PessModel.RegistrationOption AddonItem = null;
    if (Model != null && Model.RegistrationOptions.Count > 0)
    {
        BasicItem = Model.RegistrationOptions.FirstOrDefault();
        AddonItem = Model.RegistrationOptions.Where(ro => ro.Type == 1).FirstOrDefault(); //1 is for optional items
    }
}

<h2>Registration</h2>

@if (Model != null && Model.Status > 0)//registration is completed
{
    <fieldset class="show">
        <div class="heading" style="margin-top:-15px;">
            Registration completed
        </div>
        <br />
        <p>Thank you for your registration!</p>

        <p>Registration onfirmation number: <strong>@Model.PayId</strong></p>

        <p>Registered on: <strong>@Model.OverTime</strong></p>

        <p>Paid amount: <strong>¥@Model.Paid.Value.ToString("N")</strong></p>

        <p>Pay type: <strong>@Model.PayType</strong></p>

    </fieldset>

    <p>
        @Html.ActionLink("Back to Home", "Index", "Author")
    </p>
}
else//the registration is not completed
{
    using (Html.BeginForm())
    {

        <fieldset class="create">
            <div class="heading" style="margin-top:-15px;">
                Registration is not available.
            </div>
          </fieldset>

        @*@Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <div style="height:50px; margin-left:20px">
            <span style="font-weight:bold; font-size:larger">1. Choose Registration Options</span><span> - 2. Personal Information - 3. Confirm - 4. Pay to complete</span>
        </div>
        <fieldset class="create">
            <div class="heading" style="margin-top:-15px;">
                Choose Registration Options
            </div>
            <div class="editor-label">
                Registration Type:
            </div>
            <div class="editor-field editor-field-rules" style="height:130px">
                @foreach (var item in lstBasicItems)
                {
                    <input type="radio" name="BasicItemId" value="@item.Id" required @(BasicItem != null && BasicItem.Id == item.Id ? "checked" : "") />  <strong>@item.Name </strong>@(" - ¥" + item.RegularFeeRMB.ToString("N") + (item.EarlyFeeRMB != item.RegularFeeRMB ? " (Early bird ¥" + item.EarlyFeeRMB.ToString("N") + " by" + item.EarlyDate.ToShortDateString() + ")" : ""))<br />
                }
                <span class="field-validation-valid" data-valmsg-for="BasicItemId" data-valmsg-replace="false">You need to choose a registration type.</span>
            </div>
            <div class="editor-label">
                Optional:
            </div>
            <div class="editor-field">
                @foreach (var item in lstAddonItems)
                {
                    <input type="checkbox" name="AddonItemId" value="@item.Id" @(AddonItem != null && AddonItem.Id == item.Id ? "checked" : "") />  <strong>@item.Name</strong> @("- ¥" + item.RegularFeeRMB.ToString("N"))
                }
                <a href="http://www.meet-in-shanghai.net/highlights/night/shanghai-night" target="_blank">See more about Shanghai Huangpu River Night Cruise</a>
            </div>
            <div class="editor-label">
                Preference:
            </div>
            <div class="editor-field">
                <input type="radio" name="Preference" value="0" checked /> Non-vegetarian <input type="radio" name="Preference" value="1" /> Vegetarian
            </div>

            <div class="editor-btn">
                <input type="submit" value="Continue" /> <span style="color:red;padding-left:20px" id="iewarning"></span>
            </div>
        </fieldset>*@

    }//end of form
    
}

<script type="text/javascript">
    $("#iewarning").hide();

        function getInternetExplorerVersion()
            // Returns the version of Internet Explorer or a -1
            // (indicating the use of another browser).
        {
            var ver = -1; // Return value assumes failure.
                           var ua = window.navigator.userAgent;
                var msie = ua.indexOf('MSIE ');
                var trident = ua.indexOf('Trident/');

                if (msie > 0) {
                    // IE 10 or older => return version number
                    ver=parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
                }

                if (trident > 0) {
                    // IE 11 (or newer) => return version number
                    var rv = ua.indexOf('rv:');
                    ver= parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
                }
                return ver;

        }
        function checkVersion() {
            var msg = "You're not using Internet Explorer.";
            var ver = getInternetExplorerVersion();
            var expectedver = 10.0;


            if (ver>-1) {
                msg = "You're using a recent copy of Internet Explorer."
                //if(ver<9)
                //{
                //    $("#iewarning").html("Please use Internet Explorer to continue the registration.")
                //    $("#iewarning").show();
                //}
            }
            else {
                //alert("Your browser is not compatible，please use Internet Explorer 8.0 or higher version");
                $("#iewarning").html("Please use Internet Explorer to continue the registration.")
                $("#iewarning").show();
            }

        }
        checkVersion();

</script>

